/**
 * LY.com Inc.
 * Copyright (c) 2004-2019 All Rights Reserved.
 */
package com.gitee.kamismile.gatewayWeb.component.server;

import com.gitee.kamismile.gatewayWeb.component.handler.WebSocketServerInitializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author dong.li
 * @version $Id: WebSocketConfiguration, v 0.1 2019/2/22 15:55 dong.li Exp $
 */
@Configuration
@ComponentScan(basePackages = "com.gitee.kamismile.gatewayWeb")
public class WebSocketConfiguration {

    @Autowired
    private WebSocketConstant webSocketConstant;

//    @Autowired
//    private SnowflakeIdWorker snowflakeIdWorker;
//
//    @Bean
//    public SnowflakeIdWorker snowflakeIdWorker() {
//        return new SnowflakeIdWorker(ValueUtils.isLongNull(webSocketConstant.getRouter()),
//                ValueUtils.isLongNull(webSocketConstant.getRouter().subSequence(0, 1)));
//    }


    @Bean
    @ConditionalOnMissingBean(WebSocketServerInitializer.class)
    public WebSocketServerInitializer webSocketServerInitializer() {
        WebSocketServerInitializer serverInitializer = new WebSocketServerInitializer();
        serverInitializer.setWebSocketConstant(webSocketConstant);
        return serverInitializer;
    }
}
